package com.gege.homework10.autoconfigure;

import com.zaxxer.hikari.HikariDataSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.sql.DataSource;

/**
 * 自动配置 HikariDataSource
 *
 * @author gechenpeng
 * @date 2021-04-21
 */
@Configuration
public class DataSourceAutoConfiguration {

    @Bean
    public DataSource hikariDataSource() {
        HikariDataSource dataSource = new HikariDataSource();
        dataSource.setDriverClassName("com.mysql.jdbc.Driver");
        dataSource.setJdbcUrl("jdbc:mysql://localhost:3306/gogo?useUnicode=true&characterEncoding=utf-8&useSSL=false");
        dataSource.setUsername("xiaogege");
        dataSource.setPassword("imissyou");
        dataSource.setMaximumPoolSize(60);
        return dataSource;
    }
}
